package com.woniuxy.util;

import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.Map;

/**
 * 获取jwt中的用户信息
 * @version 1.0
 * @project
 * @description
 * @date 2024/3/20 15:26:16
 */
public class GetUserContent {
    public static Map getUserInfo() throws ParseException {
        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
        String jwt = request.getHeader("thoken");
        return JWTUtil.getUserInfo(jwt);
    }
}
